package com.dragon.repository.domain.vo;

import com.dragon.common.model.Update;
import com.dragon.common.util.BeanUtils;
import com.dragon.repository.entity.Procurement;
import com.dragon.repository.entity.ProcurementProduct;
import com.dragon.repository.entity.WorkflowJson;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

import javax.validation.constraints.NotNull;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;


/**
 * @author sy
 */
@Data
@ApiModel(value = "")
public class ProcurementVO {

    private static final long serialVersionUID = 1L;

    private Integer id;

    @ApiModelProperty(value = "采购编号")
    private String procuredCode;

    @ApiModelProperty(value = "采购标题")
    private String title;

    @ApiModelProperty(value = "采购人id")
    private Integer procuredAdminId;

    @ApiModelProperty(value = "采购人部门id")
    private Integer procuredDepartmentId;

    @ApiModelProperty(value = "供应商id")
    private Integer vendorId;

    @ApiModelProperty(value = "备注")
    private String remark;

    @ApiModelProperty(value = "审核状态：0未审核1审核通过2不通过")
    private Integer status;

    @ApiModelProperty(value = "采购总金额")
    private Double procuredPrice;

    @ApiModelProperty(value = "采购时间")
    @JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8")
    private Date procuredTime;

    @ApiModelProperty(value = "创建时间")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    private Date createTime;

    @ApiModelProperty(value = "修改时间")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    private Date updateTime;

    @ApiModelProperty(value = "到货时间")
    @JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8")
    private Date arrivalTime;

    @ApiModelProperty(value = "类型：1采购2退货")
    private Integer procuredState;

    @ApiModelProperty(value = "是否从请购单来：1否2是")
    private Integer isPurchase;

    @ApiModelProperty(value = "到货状态：0未发货1已发货2已到货3已退货")
    private Integer arrivalState;

    @ApiModelProperty(value = "创建人id")
    private Integer adminId;

    @ApiModelProperty(value = "部门id")
    private Integer departmentId;

    @ApiModelProperty(value = "采购人名称")
    private String procuredAdminName;

    @ApiModelProperty(value = "采购人部门名称")
    private String procuredDepartmentName;

    @ApiModelProperty(value = "采购物品list")
    private List<ProcurementProduct> procurementProductList;

    @ApiModelProperty(value = "工作流json")
    private List<WorkflowJson> workflowJsonList;

    @ApiModelProperty(value = "请购单ids")
    private String purchaseIds;

    @ApiModelProperty(value = "供应商名称")
    private String vendorName;

    @ApiModelProperty(value = "免审操作：0，不免审，1免审")
    private Integer exempt;


    @NotNull(groups = Update.class,message = "主键不能为空")
    public static Procurement convert(ProcurementVO vo) {
        Procurement entity = new Procurement();
        BeanUtils.copyProperties(vo,entity);
        return entity;
    }
    public static List<Procurement> convertList(List<ProcurementVO> list) {
        List<Procurement> resultList = new ArrayList<>();
        for (ProcurementVO vo : list) {
            resultList.add(convert(vo));
        }
        return resultList;
    }
}
